<%-- 
    Document   : visit
    Created on : Nov 25, 2012, 3:08:00 PM
    Author     : fkiss
--%>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>

<s:useActionBean beanclass="cz.muni.fi.pa165.web.SecurityActionBean" var="securityBean"/>
<f:message key="title.visitlist" var="headline"/>
<s:layout-render name="/layout.jsp" headline="${headline}">
    <s:layout-component name="content">
        <s:useActionBean beanclass="cz.muni.fi.pa165.web.VisitsActionBean" var="actionBean"/>
        <s:form beanclass="cz.muni.fi.pa165.web.VisitsActionBean">
            <s:submit name="all"><f:message key="show"/></s:submit>
            
        <table class="searchtable">
            <tr>
                <th><s:label for="1" name="visit.forest"/></th>
		<td><s:select id="1" name="visit.forest">
				<s:options-collection class="cz.muni.fi.pa165.portalnahouby.api.dto.ForestDTO" collection="${actionBean.forests}" value="id" label="name"/>
			</s:select></td>
                <th><s:label for="1" name="sortBy:"><f:message key="sortBy"/></s:label></th>
                <td><s:submit name="forest"><f:message key="sortByforest"/></s:submit></td>
                <td><s:submit name="date"><f:message key="visit.visitDate"/></s:submit></td>
                <td><s:submit name="picker"><f:message key="visit.picker"/></s:submit></td>
            </tr>
        </table>
        </s:form>
        <table class="listtable">
            <tr>
                <th width="10%"><f:message key="visit.visitDate"/></th>
                <th width="35%"><f:message key="visit.description"/></th>
                <th width="20%"><f:message key="visit.forest"/></th>
                <th width="20%"><f:message key="visit.picker"/></th>
                <th width="5%"></th>
                <th width="5%"></th>
            </tr>
            <c:forEach items="${actionBean.visits}" var="visit" varStatus="status">
                <tr class="${(status.count % 2 == 0 ) ? "even" : "odd"}">
                   <td><fmt:formatDate value="${visit.visitDate}" timeStyle="No" /></td>
                    
                    <td><c:out value="${visit.description}"/></td>
                    <td><c:out value="${visit.forest.name}"/></td>
                    <td><c:out value="${visit.picker.login}"/></td>
                    <td><c:if test="${securityBean.isAdminLoggedIn or securityBean.currentUserID eq visit.picker.id}"><s:link beanclass="cz.muni.fi.pa165.web.VisitsActionBean" event="edit"><s:param name="visit.id" value="${visit.id}"/><f:message key="edit"/></s:link></c:if> </td>
                    <td><c:if test="${securityBean.isAdminLoggedIn or securityBean.currentUserID eq visit.picker.id}"><s:link beanclass="cz.muni.fi.pa165.web.VisitsActionBean" event="delete" class="deleteentity" title="${visit.forest.name} ${visit.visitDate}"><s:param name="visit.id" value="${visit.id}"/><f:message key="delete"/></s:link></c:if> </td>
                </tr>
            </c:forEach>
        </table>
        <s:form beanclass="cz.muni.fi.pa165.web.VisitsActionBean">
            <fieldset><legend><f:message key="new"/></legend>
                <%@include file="visitform.jsp"%>
            <s:submit name="add"><f:message key="create"/></s:submit>
            </fieldset>
        </s:form>
    </s:layout-component>
</s:layout-render>
